#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char lookahead;

void expr();
void term();
void factor();
void error();

void match(char c) {
    if (lookahead == c) {
        lookahead = getchar();
    } else {
        error();
    }
}

void error() {
    printf("syntax error\n");
    exit(1);
}

void expr() {
    term();
    while (lookahead == '+' || lookahead == '-') {
        match(lookahead);
        term();
    }
}

void term() {
    factor();
    while (lookahead == '*' || lookahead == '/') {
        match(lookahead);
        factor();
    }
}

void factor() {
    if (isdigit(lookahead)) {
        while (isdigit(lookahead)) {
            match(lookahead);
        }
    } else if (lookahead == '(') {
        match('(');
        expr();
        match(')');
    } else {
        error();
    }
}

int main() {
    lookahead = getchar();
    expr();
    if (lookahead != '\n') {
        error();
    }
    printf("syntax is correct\n");
    return 0;
}